export default {
	name: "create-task",
	data() {
		return {
			action: "add",
			colWidth: 8,
			itemWidth: 22,
			formItems: [
				{"label": "编号", "kind": "input", "prop": "id", "isEdit": false, "disabled": true},
				{"label": "名称", "kind": "input", "prop": "name", "isEdit": false, "disabled": false},
				{"label": "标题", "kind": "input", "prop": "title", "isEdit": false, "disabled": false},
				{"label": "状态", "kind": "input", "prop": "status", "isEdit": false, "disabled": false},
				{"label": "触发条件", "kind": "input", "prop": "trigger", "isEdit": false, "disabled": false},
				{"label": "表达式", "kind": "input", "prop": "expression", "isEdit": false, "disabled": false}
			],
			formParams: {}
		};
	},
	created() {
		this.handleParams(this.$route);
	},
	methods: {
		handleSave(formParams) {
			this.formParams = formParams;
			console.log(this.formParams);
		},
		handleReset() {
			this.formParams = {};
		},
		handleParams(route) {
			if (route.params && route.params.action === "update") {
				this.action = "update";
				this.formParams = route.params.data;
			} else {
				this.action = "add";
				this.formParams = {};
			}
			this.formHandler.updateEditStatus(this.action, this.formItems);
			console.log(this.action);
		}
	},
	watch: {
		//监听路由的变化来实现添加或切换tab
		$route(to) {
			this.handleParams(to);
		}
	}
};
